package hu;

import java.util.*;

public class die_book {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().replaceAll("\\[","").
                replaceAll("]","").split(",");
        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < s.length; i += 2) {
            list.add(new int[]{Integer.parseInt(s[i]), Integer.parseInt(s[i + 1])});
        }
        Collections.sort(list, (a, b) ->{
            if(a[0] == b[0])
                return b[1] - a[1];
            return a[0] - b[0];
        });
        int[] dp = new int[s.length];
        int ans = 0;
        dp[0] = 1;
        for (int i = 1; i < s.length / 2; i++) {
            for (int j = 0; j < i; j++) {
                if(list.get(i)[1] > list.get(j)[1])
                    dp[i] = Math.max(dp[i], dp[j] + 1);
            }
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);
    }
}
/*
[[20,16],[15,11],[10,10],[9,10]]
 */